package com.unswift.api;

import java.lang.annotation.Annotation;
import java.util.List;

import com.unswift.annotation.api.Api;
import com.unswift.annotation.api.ApiConstructor;
import com.unswift.annotation.api.ApiField;
import com.unswift.annotation.api.ApiMethod;
import com.unswift.utils.ClassUtils;

@Api(value="Api注解处理类", author = "unswift", date = "2023-08-27", version = "1.0.0")
public class ApiHandle {

	@ApiField("类路径表达式")
	protected static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
	
	@ApiField("扫描的包")
	private List<String> scanPackages;
	
	@ApiConstructor("默认构造")
	public ApiHandle() {
		
	}
	
	@ApiConstructor(value="带参构造", params = @ApiField("需要扫描的包"))
	public ApiHandle(List<String> scanPackages) {
		super();
		this.scanPackages = scanPackages;
	}

	@ApiMethod(value="设置扫描的包", params = @ApiField("需要扫描的包"))
	public void setScanPackages(List<String> scanPackages) {
		this.scanPackages = scanPackages;
	}
	
	@ApiMethod(value="获取扫描的包", returns = @ApiField("获取扫描的包"))
	public List<String> getScanPackages() {
		return scanPackages;
	}
	
	@ApiMethod(value="获取包含Api注解的类列表", params = @ApiField("包含指定注解的类"), returns = @ApiField("包含Api注解的类列表"))
	public List<Class<?>> getApiClassList(List<Class<? extends Annotation>> apiAnnotationClassList){
		return ClassUtils.findAnnotationList(scanPackages, apiAnnotationClassList);
	}
	
}
